Skip to content

Computer Graphics - Transformation include the following topics: Linear Transformation, Homogeneous Coordinates, Affine Transformations, Inverse Transform, Composing Transform, 3D Transformations, Rodrigues' Rotation Formula.


CG-Modeling Transformation

Linear Transformation

Scale Matrix

zLEuNc

[xy]=[sx00sy][xy]

Reflection Matrix

yzwFEy

Horizontal reflection:

  • x=x
  • y=y
[xy]=[1001][xy]

Shear Matrix

LOFKoE

  • Horizontal shift is 0 at y=0
  • Horizontal shift is a at y=1
  • Vertical shift is always 0
[xy]=[1a01][xy]

Rotation Matrix

M0PdYf

Rθ=[cosθsinθsinθcosθ]Rθ=Rθ1=RθT

Homogeneous Coordinates

Add a third coordinate (w-coordinate):

  • 2D point:p=(x,y,1)T
  • 2D vector:v=(x,y,0)T

Valid operations if w-coordinate of result is 1 or 0:

  • vector + vector = vector
  • point point = vector
  • point + vector = point
  • point + point = ??
[xyw] is the 2D point [xwyw1],w0
[xyw]=[10tx01ty001][xy1]=[x+txy+ty1]

Affine Transformations

Affine map = linear map + translation:

[xy]=[abcd][xy]+[txty]

Using homogeneous coordinates:

[xy1]=[abtxcdty001][xy1]

Scale:

S(sx,sy)=[sx000sy0001]

Rotation:

R(α)=[cosαsinα0sinαcosα0001]

Translation:

GDBFNF

T(tx,ty)=[10tx01ty001]

Inverse Transform

M1M1 is the inverse of transform M in both a matrix and geometric sense.

xxvNp0

Composing Transform

Transform Ordering Matters!

Matrix multiplication is not commutative:

R45T(1,0)T(1,0)R45

Note that matrices are applied right to left:

T(1,0)R45[xy1]=[101010001][cos45sin450sin45cos450001][xy1]

Sequence of Affine Transforms

  • Compose by matrix multiplication
  • Very important for performance!
An(A2(A1(x)))=AnA2A1(xy1)

Pre-multiply n matrices to obtain a single matrix representing the combined transform.

How to rotate around a given point c?

  1. Translate center to origin
  2. Rotate
  3. Translate back

Ez3SaS

Matrix representation:

T(c)R(α)T(c)

3D Transformations

Use homogeneous coordinates again:

  • 3D point:

    (x,y,z,1)T
  • 3D vector:

    (x,y,z,0)T

In general, (x,y,z,w) (w0) is the 3D point:

(xw,yw,zw)

Use 4×4 Matrices for Affine Transformations

(xyz1)=(abctxdeftyghitz0001)(xyz1)

Order: Linear transformations, then translation.

Scale

S(sx,sy,sz)=(sx0000sy0000sz00001)

Translation

T(tx,ty,tz)=(100tx010ty001tz0001)

Rotation

Rotation around the x-axis:

Rx(α)=(10000cosαsinα00sinαcosα00001)

Rotation around the y-axis:

Ry(α)=(cosα0sinα00100sinα0cosα00001)

Rotation around the z-axis:

Rz(α)=(cosαsinα00sinαcosα0000100001)

Compose Any 3D Rotation from Rx, Ry, Rz

Rxyz(α,β,γ)=Rx(α)Ry(β)Rz(γ)
  • So-called Euler angles
  • Often used in flight simulators: roll, pitch, yaw

Rodrigues' Rotation Formula

Rotation by angle α around axis n

R(n,α)=cos(α)I+(1cos(α))nnT+sin(α)NN=(0nznynz0nxnynx0)